package com.ruoyi.house.controller;

import java.util.List;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.house.domain.YjzAudit;
import com.ruoyi.house.service.IYjzAuditService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 房源审核Controller
 * 
 * @author 码道可道
 * @date 2025-07-14
 */
@RestController
@RequestMapping("/house/audit")
public class YjzAuditController extends BaseController
{
    @Autowired
    private IYjzAuditService yjzAuditService;

    /**
     * 查询房源审核列表
     */
    @PreAuthorize("@ss.hasPermi('house:audit:list')")
    @GetMapping("/list")
    public TableDataInfo list(YjzAudit yjzAudit)
    {
        startPage();
        List<YjzAudit> list = yjzAuditService.selectYjzAuditList(yjzAudit);
        return getDataTable(list);
    }

    /**
     * 导出房源审核列表
     */
    @PreAuthorize("@ss.hasPermi('house:audit:export')")
    @Log(title = "房源审核", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, YjzAudit yjzAudit)
    {
        List<YjzAudit> list = yjzAuditService.selectYjzAuditList(yjzAudit);
        ExcelUtil<YjzAudit> util = new ExcelUtil<YjzAudit>(YjzAudit.class);
        util.exportExcel(response, list, "房源审核数据");
    }

    /**
     * 获取房源审核详细信息
     */
    @PreAuthorize("@ss.hasPermi('house:audit:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(yjzAuditService.selectYjzAuditById(id));
    }

    /**
     * 新增房源审核
     */
    @PreAuthorize("@ss.hasPermi('house:audit:add')")
    @Log(title = "房源审核", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody YjzAudit yjzAudit)
    {
        return toAjax(yjzAuditService.insertYjzAudit(yjzAudit));
    }

    /**
     * 修改房源审核
     */
    @PreAuthorize("@ss.hasPermi('house:audit:edit')")
    @Log(title = "房源审核", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody YjzAudit yjzAudit)
    {
        return toAjax(yjzAuditService.updateYjzAudit(yjzAudit));
    }

    /**
     * 删除房源审核
     */
    @PreAuthorize("@ss.hasPermi('house:audit:remove')")
    @Log(title = "房源审核", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(yjzAuditService.deleteYjzAuditByIds(ids));
    }
}
